home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / Cell Control / DATA1.CAB / VCDEMO_Files / PrintDemoDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-01-11  |  7.4 KB  |  240 lines

  1. // PrintDemoDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "VCDemo.h"
  6. #include "PrintDemoDlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CPrintDemoDlg dialog
  16.  
  17.  
  18. CPrintDemoDlg::CPrintDemoDlg(CWnd* pParent /*=NULL*/)
  19.     : CDialog(CPrintDemoDlg::IDD, pParent)
  20. {
  21.     //{{AFX_DATA_INIT(CPrintDemoDlg)
  22.         // NOTE: the ClassWizard will add member initialization here
  23.     //}}AFX_DATA_INIT
  24. }
  25.  
  26.  
  27. void CPrintDemoDlg::DoDataExchange(CDataExchange* pDX)
  28. {
  29.     CDialog::DoDataExchange(pDX);
  30.     //{{AFX_DATA_MAP(CPrintDemoDlg)
  31.     DDX_Control(pDX, IDC_SGCTRL1, m_ctrl);
  32.     //}}AFX_DATA_MAP
  33. }
  34.  
  35.  
  36. BEGIN_MESSAGE_MAP(CPrintDemoDlg, CDialog)
  37.     //{{AFX_MSG_MAP(CPrintDemoDlg)
  38.     ON_BN_CLICKED(IDC_BUTTON_PREVIEW, OnButtonPreview)
  39.     ON_BN_CLICKED(IDC_BUTTON_PRINT, OnButtonPrint)
  40.     ON_BN_CLICKED(IDC_BUTTON_PREVIEW2, OnButtonPreview2)
  41.     //}}AFX_MSG_MAP
  42. END_MESSAGE_MAP()
  43.  
  44. /////////////////////////////////////////////////////////////////////////////
  45. // CPrintDemoDlg message handlers
  46.  
  47. void CPrintDemoDlg::OnButtonPreview2() 
  48. {
  49.     // TODO: Add your control notification handler code here
  50.     m_ctrl.DoSetCurrentPage( 1 );
  51.  
  52.     m_ctrl.DoSetCellString( 0,-1, "Stock" );    
  53.     m_ctrl.DoSetCellString( 1,-1, "Open");
  54.     m_ctrl.DoSetCellString( 2,-1, "Rise/Drop");
  55.     m_ctrl.DoSetCellString( 3,-1, "Volume" );
  56.     m_ctrl.DoSetCellString( 4,-1, "10:10" );
  57.     m_ctrl.DoSetCellString( 5,-1, "Volume" );
  58.  
  59.     m_ctrl.DoSetCellString( 0,0, "Microsoft" );    
  60.     m_ctrl.DoSetCellValue( 1,0, 27.50 );
  61.     m_ctrl.DoSetCellValue( 2,0, -0.57);
  62.     m_ctrl.DoSetCellValue( 3,0, 1116200 );
  63.     m_ctrl.DoSetCellValue( 4,0, 27.60 );
  64.     m_ctrl.DoSetCellValue( 5,0, 338700 );
  65.  
  66.     m_ctrl.DoSetCellString( 0,1, "IBM" );    
  67.     m_ctrl.DoSetCellValue( 1,1, 9.59 );
  68.     m_ctrl.DoSetCellValue( 2,1, -1.94);
  69.     m_ctrl.DoSetCellValue( 3,1, 317000 );
  70.     m_ctrl.DoSetCellValue( 4,1, 9.7);
  71.     m_ctrl.DoSetCellValue( 5,1, 45600 );
  72.  
  73.     m_ctrl.DoSetCellString( 0,2, "Oracle" );    
  74.     m_ctrl.DoSetCellValue( 1,2,11.3);
  75.     m_ctrl.DoSetCellValue( 2,2, 0.89);
  76.     m_ctrl.DoSetCellValue( 3,2, 333200 );
  77.     m_ctrl.DoSetCellValue( 4,2, 11.21 );
  78.     m_ctrl.DoSetCellValue( 5,2, 20700 );
  79.  
  80.     m_ctrl.DoSetCellString( 0,3, "Sybase" );    
  81.     m_ctrl.DoSetCellValue( 1,3, 13.52);
  82.     m_ctrl.DoSetCellValue( 2,3, -2.02);
  83.     m_ctrl.DoSetCellValue( 3,3, 378500 );
  84.     m_ctrl.DoSetCellValue( 4,3, 13.68 );
  85.     m_ctrl.DoSetCellValue( 5,3, 26500 );
  86.  
  87.     m_ctrl.DoSetCellString( 0,4, "Adobe" );    
  88.     m_ctrl.DoSetCellValue( 1,4, 15.82);
  89.     m_ctrl.DoSetCellValue( 2,4, -1.12);
  90.     m_ctrl.DoSetCellValue( 3,4, 799600 );
  91.     m_ctrl.DoSetCellValue( 4,4, 15.81 );
  92.     m_ctrl.DoSetCellValue( 5,4, 69600 );
  93.  
  94.     m_ctrl.DoSetCellString( 0,5, "Yahoo" );    
  95.     m_ctrl.DoSetCellValue( 1,5, 6.3);
  96.     m_ctrl.DoSetCellValue( 2,5, -1.4);
  97.     m_ctrl.DoSetCellValue( 3,5, 476000 );
  98.     m_ctrl.DoSetCellValue( 4,5, 6.43 );
  99.     m_ctrl.DoSetCellValue( 5,5, 195500 );
  100.  
  101.     m_ctrl.DoSetCellString( 0,6, "AOL" );    
  102.     m_ctrl.DoSetCellValue( 1,6,10.21);
  103.     m_ctrl.DoSetCellValue( 2,6, -0.68);
  104.     m_ctrl.DoSetCellValue( 3,6, 221300 );
  105.     m_ctrl.DoSetCellValue( 4,6, 10.26 );
  106.     m_ctrl.DoSetCellValue( 5,6, 21200 );
  107.  
  108.     m_ctrl.DoSetCellString( 0,7, "AT&T" );    
  109.     m_ctrl.DoSetCellValue( 1,7,9.1);
  110.     m_ctrl.DoSetCellValue( 2,7, -2.04);
  111.     m_ctrl.DoSetCellValue( 3,7, 1014800 );
  112.     m_ctrl.DoSetCellValue( 4,7, 9.12);
  113.     m_ctrl.DoSetCellValue( 5,7, 97000 );
  114.  
  115.     m_ctrl.DoSetCellString( 0,8, "North" );    
  116.     m_ctrl.DoSetCellValue( 1,8, 8.98);
  117.     m_ctrl.DoSetCellValue( 2,8, -2.07);
  118.     m_ctrl.DoSetCellValue( 3,8, 757300 );
  119.     m_ctrl.DoSetCellValue( 4,8, 9.11 );
  120.     m_ctrl.DoSetCellValue( 5,8, 154400 );
  121.  
  122.     m_ctrl.DoSetCurrentPage( 0 );
  123.  
  124.     m_ctrl.DoPrintPreviewPage( 1, TRUE );    
  125. }
  126.  
  127. void CPrintDemoDlg::OnButtonPrint() 
  128. {
  129.     // TODO: Add your control notification handler code here
  130.     m_ctrl.DoPrint(TRUE);
  131. }
  132.  
  133. BOOL CPrintDemoDlg::OnInitDialog() 
  134. {
  135.     CDialog::OnInitDialog();
  136.     
  137.     // TODO: Add extra initialization here
  138.     m_ctrl.DoSetCellString( 0,0, "interest rate" );
  139.     m_ctrl.DoSetCellString( 1,0, "3 month" );
  140.     m_ctrl.DoSetCellString( 2,0, "half year" );
  141.     m_ctrl.DoSetCellString( 3,0, "1 year" );
  142.     m_ctrl.DoSetCellString( 4,0, "2 year" );
  143.     m_ctrl.DoSetCellString( 5,0, "3 year" );
  144.     m_ctrl.DoSetCellString( 6,0, "5 year" );
  145.  
  146.     m_ctrl.DoSetCellString( 0,1, "month rate" );
  147.     m_ctrl.DoSetCellValue( 1,1, 2.4 );
  148.     m_ctrl.DoSetCellValue( 2,1, 3.45 );
  149.     m_ctrl.DoSetCellValue( 3,1, 4.725 );
  150.     m_ctrl.DoSetCellValue( 4,1, 4.95 );
  151.     m_ctrl.DoSetCellValue( 5,1, 5.175 );
  152.     m_ctrl.DoSetCellValue( 6,1, 5.55 );
  153.  
  154.     m_ctrl.DoSetCellString( 0,2, "year rate" );
  155.     m_ctrl.DoSetCellValue( 1,2, 2.88 );
  156.     m_ctrl.DoSetCellValue( 2,2, 4.14 );
  157.     m_ctrl.DoSetCellValue( 3,2, 5.67 );
  158.     m_ctrl.DoSetCellValue( 4,2, 5.94 );
  159.     m_ctrl.DoSetCellValue( 5,2, 6.21 );
  160.     m_ctrl.DoSetCellValue( 6,2, 6.66 );
  161.  
  162.  
  163.     m_ctrl.DoJoinCells( 1,4, 5,10 );
  164.     m_ctrl.DoSetRefChart( 1,4, 0,0,6,2 );
  165.  
  166.     m_ctrl.DoJoinCells( 1,11, 5,17 );
  167.     m_ctrl.DoSetChart( 1,11, 5,5 );
  168.  
  169.     m_ctrl.DoSetChartStringData( 1,11, 0,0, "Area" );
  170.     m_ctrl.DoSetChartStringData( 1,11, 1,0, "Washington" );
  171.     m_ctrl.DoSetChartStringData( 1,11, 2,0, "New York" );
  172.     m_ctrl.DoSetChartStringData( 1,11, 3,0, "Colorado" );
  173.     m_ctrl.DoSetChartStringData( 1,11, 4,0, "Florida" );
  174.  
  175.     m_ctrl.DoSetChartStringData( 1,11, 0,1, "1st quarter" );
  176.     m_ctrl.DoSetChartStringData( 1,11, 0,2, "2nd quarter" );
  177.     m_ctrl.DoSetChartStringData( 1,11, 0,3, "3rd quarter" );
  178.     m_ctrl.DoSetChartStringData( 1,11, 0,4, "4th quarter" );
  179.  
  180.     m_ctrl.DoSetChartValueData( 1,11, 1,1, 29876 );
  181.     m_ctrl.DoSetChartValueData( 1,11, 1,2, 34123 );
  182.     m_ctrl.DoSetChartValueData( 1,11, 1,3, 42221 );
  183.     m_ctrl.DoSetChartValueData( 1,11, 1,4, 52123 );
  184.  
  185.     m_ctrl.DoSetChartValueData( 1,11, 2,1, 32365 );
  186.     m_ctrl.DoSetChartValueData( 1,11, 2,2, 35432 );
  187.     m_ctrl.DoSetChartValueData( 1,11, 2,3, 30283 );
  188.     m_ctrl.DoSetChartValueData( 1,11, 2,4, 45322 );
  189.  
  190.     m_ctrl.DoSetChartValueData( 1,11, 3,1, 32007 );
  191.     m_ctrl.DoSetChartValueData( 1,11, 3,2, 23481 );
  192.     m_ctrl.DoSetChartValueData( 1,11, 3,3, 40624 );
  193.     m_ctrl.DoSetChartValueData( 1,11, 3,4, 34528 );
  194.  
  195.     m_ctrl.DoSetChartValueData( 1,11, 4,1, 31232 );
  196.     m_ctrl.DoSetChartValueData( 1,11, 4,2, 30345 );
  197.     m_ctrl.DoSetChartValueData( 1,11, 4,3, 27943 );
  198.     m_ctrl.DoSetChartValueData( 1,11, 4,4, 32119 );
  199.  
  200.     m_ctrl.DoSetChartGeneralData( 1, 11, 1, FALSE, "Sale", "Figure2", "thousand dollar");
  201.     m_ctrl.DoRefreshChart( 1, 11 );
  202.  
  203.     m_ctrl.SetPageLabelVisible( FALSE );
  204.     m_ctrl.DoAppendPage( "", 2 );
  205.     COleVariant var( "VCDEMO" );
  206.     m_ctrl.DoSetMessageTitle( var );
  207.  
  208.     return TRUE;  // return TRUE unless you set the focus to a control
  209.                   // EXCEPTION: OCX Property Pages should return FALSE
  210. }
  211.  
  212. void CPrintDemoDlg::OnButtonPreview() 
  213. {
  214.     // TODO: Add your control notification handler code here
  215.     m_ctrl.DoPrintPreview( FALSE );            
  216. }
  217.  
  218. BEGIN_EVENTSINK_MAP(CPrintDemoDlg, CDialog)
  219.     //{{AFX_EVENTSINK_MAP(CPrintDemoDlg)
  220.     ON_EVENT(CPrintDemoDlg, IDC_SGCTRL1, 55 /* OnPrint */, OnOnPrintSgctrl1, VTS_PVARIANT)
  221.     //}}AFX_EVENTSINK_MAP
  222. END_EVENTSINK_MAP()
  223.  
  224. void CPrintDemoDlg::OnOnPrintSgctrl1(VARIANT FAR* processed) 
  225. {
  226.     // TODO: Add your control notification handler code here
  227.     AfxMessageBox( "The real output was page 3( Copy from page 1)" );    
  228.  
  229.     m_ctrl.DoCopyPage( 2, 0 );
  230.     m_ctrl.DoSetCurrentPage( 2 );
  231.     m_ctrl.DoSetCellString( 0,0, "Page 3" );
  232.     m_ctrl.DoSetCurrentPage( 0 );
  233.  
  234.     COleVariant var( processed );
  235.     var = 1l;
  236.     *processed = var.Detach();
  237.  
  238.     m_ctrl.DoPrintPage( 2, TRUE );
  239. }
  240.